 package org.edu.modules.portal.controller;

 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import java.util.Arrays;
 import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 import org.edu.common.api.vo.Result;
 import org.edu.common.aspect.annotation.AutoLog;
 import org.edu.common.system.base.controller.BaseController;
 import org.edu.common.system.query.QueryGenerator;
 import org.edu.modules.portal.entity.VeSiteTemplet;
 import org.edu.modules.portal.service.IVeSiteTempletService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
















 @Api(tags = {"网站模板"})
 @RestController
 @RequestMapping({"/portal/veSiteTemplet"})
 @ApiSort(50)
 public class VeSiteTempletController
   extends BaseController<VeSiteTemplet, IVeSiteTempletService>
 {
/*  52 */   private static final Logger log = LoggerFactory.getLogger(org.edu.modules.portal.controller.VeSiteTempletController.class);







   @Autowired
   private IVeSiteTempletService veSiteTempletService;







   @AutoLog("网站模板-分页查询")
   @ApiOperation(value = "列表查询", notes = "网站模板-分页查询")
   @PostMapping({"/list"})
   @ApiOperationSupport(order = 1)
   @ApiImplicitParams({@ApiImplicitParam(name = "rowmodel", value = "站点对应的模型代码：portal=主站点，department=专业站点,xmportal=专业建设项目", required = true), @ApiImplicitParam(name = "typeid", value = "模板类型Id", required = true), @ApiImplicitParam(name = "status", value = "是否启用1启用 0 禁用", required = true)})
   public Result<?> queryPageList(@ApiIgnore VeSiteTemplet veSiteTemplet, HttpServletRequest req) {
     QueryWrapper<VeSiteTemplet> queryWrapper = QueryGenerator.initQueryWrapper(veSiteTemplet, req.getParameterMap());
     List<VeSiteTemplet> list = this.veSiteTempletService.list((Wrapper)queryWrapper);
     return Result.OK(list);
   }






   @AutoLog("网站模板-通过id查询")
   @ApiOperation(value = "通过id查询", notes = "网站模板-通过id查询")
   @PostMapping({"/queryById"})
   public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
     VeSiteTemplet veSiteTemplet = (VeSiteTemplet)this.veSiteTempletService.getById(id);
/*  90 */     if (veSiteTemplet == null) {
       return Result.error("未找到对应数据");
     }
     return Result.OK(veSiteTemplet);
   }










   @AutoLog("网站模板-启用模板")
   @ApiOperation(value = "启用模板", notes = "网站模板-启用模板")
   @PostMapping({"/setDefault"})
   @ApiOperationSupport(order = 3)
   @ApiImplicitParams({@ApiImplicitParam(name = "rowmodel", value = "站点对应的模型代码：portal=主站点，department=专业站点,xmportal=专业建设项目", required = true), @ApiImplicitParam(name = "typeid", value = "模板类型Id", required = true), @ApiImplicitParam(name = "id", value = "模板Id", required = true)})
   public Result<?> setDefault(@ApiIgnore VeSiteTemplet veSiteTemplet) {
    if (this.veSiteTempletService.setDefault(veSiteTemplet) > 0) {
       return Result.OK("启用模板成功!");
     }
     return Result.error("操作失败");
   }







   @AutoLog("网站模板-新增信息")
   @ApiOperation(value = "新增信息", notes = "网站模板-新增信息")
   @PostMapping({"/add"})
   public Result<?> add(@RequestBody VeSiteTemplet veSiteTemplet) {
     if (this.veSiteTempletService.save(veSiteTemplet)) {
       return Result.OK("添加成功！");
     }
     return Result.error("操作失败");
   }







   @AutoLog("网站模板-修改信息")
   @ApiOperation(value = "修改信息", notes = "网站模板-修改信息")
   @PostMapping({"/edit"})
   public Result<?> edit(@RequestBody VeSiteTemplet veSiteTemplet) {
     if (this.veSiteTempletService.updateById(veSiteTemplet)) {
       return Result.OK("编辑成功!");
     }
     return Result.error("操作失败");
   }






   @AutoLog("网站模板-通过id删除")
   @ApiOperation(value = "通过id删除", notes = "网站模板-通过id删除")
   @PostMapping({"/delete"})
   public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
     if (this.veSiteTempletService.removeById(id)) {
       return Result.OK("删除成功!");
     }
     return Result.error("操作失败");
   }








   @AutoLog("网站模板-批量删除")
   public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
     if (this.veSiteTempletService.removeByIds(Arrays.asList(ids.split(",")))) {
       return Result.OK("批量删除成功!");
     }
/* 176 */     return Result.error("操作失败");
   }
 }



